#include<iostream>
#include<map>

using namespace std;
int main()
{
	map<string , size_t> wCount;
	string word;
	while(cin>>word){
		++wCount[word];
	} 
	for(auto& w : wCount){
		cout<<w.first<<" "<<w.second<<endl;
	}
}
